package com.ds.service.impl;

import cn.hutool.core.util.RandomUtil;

import com.ds.datasource.DS;
import com.ds.datasource.DsConstant;
import com.ds.entity.User;
import com.ds.mapper.UserMapper;
import com.ds.service.IUserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户实现类
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    UserMapper userMapper;

    @DS(DsConstant.DS1)
    @Override
    public List<User> findAll() {
        return userMapper.selectAll();
    }

    @DS(DsConstant.DS1)
    @Override
    public void add() {
        User user = new User();
        user.setName("张三001-" + RandomUtil.randomInt());
        user.setAge(RandomUtil.randomInt());
        user.setSex("男");
        userMapper.insertUser2(user);
    }
}
